const app = getApp()
Page({
  data: {
    scrollViewHeight: 0,
    navbar: ['口述史', '个人志', '纪录片', 'AR记录'],
    currentTab: 0,
    works: [{
        imgUrl: '/images/1.jpg',
        title: '西子河畔'
      },
      {
        imgUrl: '/images/2.jpg',
        title: '与她携手那些年'
      },
      {
        imgUrl: '/images/3.jpg',
        title: '老杨的故事'
      },
      {
        imgUrl: '/images/4.jpg',
        title: '轰轰烈烈三十年'
      },
      {
        imgUrl: '/images/5.jpg',
        title: '红旗正当空'
      },
      {
        imgUrl: '/images/4.jpg',
        title: '轰轰烈烈三十年'
      }
    ]
  },
  onLoad: function (e) {
    let that = this
    let query = wx.createSelectorQuery().in(that);
    // 取出navbar的节点信息
    // 选择器的语法与jQuery语法相同
    query.select('.navbar').boundingClientRect();
    query.exec(res => {
      console.log("res:")
      console.log(res)
      // 分别取出navbar的高度
      let navbarHeight = res[0].height;
      console.log("screenHeight:")
      console.log(wx.getSystemInfoSync().screenHeight)
      let windowHeight = wx.getSystemInfoSync().windowHeight
      console.log("windowHeight:" + windowHeight)
      // 然后就是做个减法
      let scrollViewHeight = windowHeight - navbarHeight
      console.log("scrollViewHeight:" + scrollViewHeight)
      // 算出来之后存到data对象里面
      that.setData({
        scrollViewHeight: scrollViewHeight
      });
      console.log("data:")
      console.log(that.data)
    });

  },
  navbarTap: function (e) {
    this.setData({
      currentTab: e.currentTarget.dataset.idx
    })
  },
  swiperChange: function (e) {
    this.setData({
      currentTab: e.detail.current
    })
  }
})